// 云函数入口文件
const cloud = require('wx-server-sdk')
const got = require('got'); //引用 gotnpm i got@9.6.0 --save

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  if (event.data != "") {
    var tdata = event.data;
    if (typeof (tdata) == undefined) {
      return ""
    }
    console.log(tdata);
    let postResponse = await got('url', {
      method: 'POST', //post请求
      headers: { 'Content-Type': 'application/json' },
      body: tdata
    })
    return postResponse.body //返回数据
  } else {
    return ""
  }
}
